from Base.Base import Base
from selenium.webdriver.common.by import By
import time

#登录业务
class Page1(Base):
    #点击登录 /html/body/div[1]/div/div[2]/ul/li[1]/a
    deng_loc = (By.XPATH, '/html/body/div[1]/div/div[2]/ul/li[1]/a')

    def deng(self):
        self.click(self.deng_loc)

    #断言 会员登录 class="reg-new"
    dy1_loc = (By.CLASS_NAME, 'reg-new')

    def dy1(self):
        return self.text(self.dy1_loc)

    #输入帐号 name="username"
    username_loc = (By.NAME, 'username')

    def username(self):
        self.send_keys(self.username_loc, '13811033962')

    #输入密码 name="password"
    password_loc = (By.NAME, 'password')

    def password(self):
        self.send_keys(self.password_loc, '123456')

    #点击登录 class="finish-btn"
    dengan_loc = (By.CLASS_NAME, 'finish-btn')

    def dengan(self):
        self.click(self.dengan_loc)

    #断言欢迎回来 /html/body/div[1]/div/div[2]/ul/li[1]/a
    dy2_loc = (By.XPATH, '/html/body/div[1]/div/div[2]/ul/li[1]/a')

    def dy2(self):
        return self.text(self.dy2_loc)

    def test_A3mall_001(self):
        self.open_url('http://10.59.9.14:7003/')
        self.deng()
        time.sleep(3)
        self.dy1()
        print(self.dy1())
        self.username()
        self.password()
        time.sleep(10)
        self.dengan()
        time.sleep(3)
        self.dy2()
        print(self.dy2())
